package org.edu.modules.kwgl.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.edu.modules.kwgl.entity.VeJwBukao;
import org.edu.modules.kwgl.entity.VeJwQingkao;
import org.edu.modules.kwgl.mapper.VeJwBukaoMapper;
import org.edu.modules.kwgl.service.IVeJwBukaoService;
import org.edu.modules.scheduleCommon.dto.BasePageDto;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;

/**
 * @Description: 补考信息
 * @Author: jeecg-boot
 * @Date:   2021-05-11
 * @Version: V1.0
 */
@Service
public class VeJwBukaoServiceImpl extends ServiceImpl<VeJwBukaoMapper, VeJwBukao> implements IVeJwBukaoService {


    @Override
    public IPage<VeJwBukao> pageDto(BasePageDto page, Wrapper queryWrapper) {
        return baseMapper.pageDto(page, queryWrapper);

    }

    @Override
    public void changePublishById(int id, int status) {
        baseMapper.updateById(new VeJwBukao().setId(id).setIspublish(status));
    }

    @Override
    public void updateStatusByIds(String ids, int status) {
        List<String> list = Arrays.asList(ids.split(","));
        for (String str:list) {
            baseMapper.updateById(new VeJwBukao().setId(Integer.parseInt(str)).setStatus(status));
        }
    }

    @Override
    public VeJwBukao  getByKcid(int kcid) {
        return baseMapper.selectOne(new QueryWrapper<VeJwBukao>()
                .eq("kcId",kcid)
                .eq("isPublish",1)
                .orderByDesc("createTime")
                .last("LIMIT 1"));
    }
}
